<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .container {
      position: absolute;
      width: 200px;
      height: 400px;
      background-color: pink;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
    /* 
      1. composition api中computed的使用
      2. 简单用法
      - 参数为函数
      3. 复杂用法
      - 参数为对象
        - get/set
    */

    const app = Vue.createApp({
      template: `
      <div class="container" >
        <todolist />
      </div>
    `,
    })
    app.component('todolist', {
      template: `
      <div class="container" >
        {{count}} -- {{result}}
        <button @click="handleClick">增加</button>
      </div>
      `,
      setup(props, context) {
        const { ref, computed } = Vue
        const count = ref(0)
        const result = computed(() => {
          return count.value + 5
        })
        const handleClick = () => {
          count.value++
        }
        return {
          count, result, handleClick
        }
      }
    })
    const vm = app.mount('#root');

  </script>
</body>

</html>